home *** CD-ROM | disk | FTP | other *** search
- #! /bin/sh
- count=10000
- sleep=1
- while [ $# -gt 0 ]
- do
- case "$1" in
- -s) sleep=0; shift;;
- [0-9]*) count="$1" ; shift;;
- *) break 2;;
- esac
- done
-
- nawk '
- BEGIN { FS = ":"; srand() }
- $1 !~ /^#/ && NF == 2 { host[hcount++] = $1 }
- func do_addr(count, i) {
- printf "mail -s \"mesg %d\" ", msgcount ++
- for (i = 0; i < count; i++) {
- printf "foo@%s ", host[random(hcount)]
- }
- printf "< /etc/hosts\n"
- }
- func random(n) { return int(rand*n); }
- END {
- print "#! /bin/sh"
- print "echo hcount is", hcount, "producing", tcount, "records"
- for(n = 0;n < tcount;n++) {
- if (random(4) == 1)
- do_addr(random(10)+1)
- else do_addr(1)
- if(sleep)
- print "sleep", random(5)+1
- }
- }' sleep="$sleep" tcount="$count" $*
-